home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Creative Computers
/
Creative Computers CD-ROM, Volume 1 (Legendary Design Technologies, Inc.)(1994).iso
/
text
/
info
/
gif_specs.pp
/
gif_specs
Wrap
Text File
|
1994-11-17
|
23KB
|
562 lines
G I F
Graphics Interchange Format
A standard defining a mechanism
for the storage and transmission
of raster-based graphics information
May 1, 1987
(c) CompuServe Incorporated, 1987
All rights reserved
CompuServe Incorporated
5000 Arlington Centre Blvd.
Columbus, Ohio 43220
(614) 457-8600
Page 2
CompuServe Graphics Interchange Format (GIF) Specification
Table of Contents
INTRODUCTION . . . . . . . . . . . . . . . . . page 3
GENERAL FILE FORMAT . . . . . . . . . . . . . page 3
GIF SIGNATURE . . . . . . . . . . . . . . . . page 4
SCREEN DESCRIPTOR . . . . . . . . . . . . . . page 4
GLOBAL COLOR MAP . . . . . . . . . . . . . . . page 4
IMAGE DESCRIPTOR . . . . . . . . . . . . . . . page 5
LOCAL COLOR MAP . . . . . . . . . . . . . . . page 6
RASTER DATA . . . . . . . . . . . . . . . . . page 6
GIF TERMINATION . . . . . . . . . . . . . . . page 7
APPENDIX A - GLOSSARY . . . . . . . . . . . . page 8
APPENDIX B - INTERACTIVE SEQUENCES . . . . . . page 9
APPENDIX C - IMAGE PACKAGING & COMPRESSION . . page 11
Graphics Interchange Format (GIF) Page 3
Specification
INTRODUCTION
'GIF' is CompuServe's standard for defining generalized color
raster images. This 'Graphics Interchange Format' allows
high-quality, high-resolution graphics to be displayed on a variety of
graphics hardware and is intended as an exchange and display mechanism
for graphics images. The image format described in this document is
designed to support current and future image technology and will in
addition serve as a basis for future CompuServe graphics products.
The main focus of this document is to provide the technical
information necessary for a programmer to implement GIF encoders and
decoders. As such, some assumptions are made as to terminology
relavent to graphics and programming in general.
The first section of this document describes the GIF data format
and its components and applies to all GIF decoders, either as
standalone programs or as part of a communications package. Appendix
B is a section relavent to decoders that are part of a communications
software package and describes the protocol requirements for entering
and exiting GIF mode, and responding to host interrogations. A
glossary in Appendix A defines some of the terminology used in this
document. Appendix C gives a detailed explanation of how the graphics
image itself is packaged as a series of data bytes.
Graphics Interchange Format Data Definition
GENERAL FILE FORMAT
+-----------------------+
| +-------------------+ |
| | GIF Signature | |
| +-------------------+ |
| +-------------------+ |
| | Screen Descriptor | |
| +-------------------+ |
| +-------------------+ |
| | Global Color Map | |
| +-------------------+ |
. . . . . .
| +-------------------+ | ---+
| | Image Descriptor | | |
| +-------------------+ | |
| +-------------------+ | |
| | Local Color Map | | |- Repeated 1 to n times
| +-------------------+ | |
| +-------------------+ | |
| | Raster Data | | |
| +-------------------+ | ---+
. . . . . .
|- GIF Terminator -|
+-----------------------+
Graphics Interchange Format (GIF) Page 4
Specification
GIF SIGNATURE
The following GIF Signature identifies the data following as a
valid GIF image stream. It consists of the following six characters:
G I F 8 7 a
The last three characters '87a' may be viewed as a version number
for this particular GIF definition and will be used in general as a
reference in documents regarding GIF that address any version
dependencies.
SCREEN DESCRIPTOR
The Screen Descriptor describes the overall parameters for all
GIF images following. It defines the overall dimensions of the image
space or logical screen required, the existance of color mapping
information, background screen color, and color depth information.
This information is stored in a series of 8-bit bytes as described
below.
bits
7 6 5 4 3 2 1 0 Byte #
+---------------+
| | 1
+-Screen Width -+ Raster width in pixels (LSB first)
| | 2
+---------------+
| | 3
+-Screen Height-+ Raster height in pixels (LSB first)
| | 4
+-+-----+-+-----+ M = 1, Global color map follows Descriptor
|M| cr |0|pixel| 5 cr+1 = # bits of color resolution
+-+-----+-+-----+ pixel+1 = # bits/pixel in image
| background | 6 background=Color index of screen background
+---------------+ (color is defined from the Global color
|reserved (zero)| 7 map or default map if none specified)
+---------------+
GLOBAL COLOR MAP
The Global Color Map is optional but recommended for images where
accurate color rendition is desired. The existence of this color map
is indicated in the 'M' field of byte 5 of the Screen Descriptor. A
color map can also be associated with each image in a GIF file but
will normally use this global map because of hardware restrictions in
equipment available today. In the individual Image Descriptors the
'M' flag will normally be zero. If the Global Color Map is present,
it's definition immediately follows the Screen Descriptor. The number
of color map entries following a Screen Descriptor is equal to
2**(# bits per pixel), where each entry consists of three byte values
representing the relative intensities of red, green and blue
respectively. Each pixel value received is displayed according to its
Graphics Interchange Format (GIF) Page 5
Specification
closest match with an available color on the display based on this
color map. The color components represent a fractional intensity
value from none (0) to full (255). White would be represented as
(255,255,255), black as (0,0,0) and medium yellow as (180,180,0). For
display, if the device supports fewer than 8 bits per color component,
the higher order bits of each component are used. In the creation of
a GIF color map entry with hardware supporting fewer than 8 bits per
component, the component values for the hardware should be converted
to the 8-bit format with the following calculation:
<map_value> = <component_value>*255/(2**<nbits> -1)
This assures accurate translation of colors for all displays. If
no Global Color Map is indicated, a default color map is generated
internally which maps each incoming color index to a hardware color
index.
IMAGE DESCRIPTOR
The Image Descriptor defines the actual placement and extents of
the following image within the space defined in the Screen Descriptor.
Also defined are flags to indicate the presence of a local color
lookup map, and to define the pixel display sequence. Each Image
Descriptor is introduced by an image separator character. The role of
the Image Separator is